#include <php.h>
#include "spi_library.h"
#include <wiringPiSPI.h>

//spi-library
PHP_FUNCTION(wiringPiSPISetup)
{
    long channel;
    long speed;

    ZEND_PARSE_PARAMETERS_START(2, 2)
        Z_PARAM_LONG(channel)
        Z_PARAM_LONG(speed)
    ZEND_PARSE_PARAMETERS_END();

    long ret = wiringPiSPISetup(channel, speed);
    RETURN_LONG(ret);
}


PHP_FUNCTION(wiringPiSPIDataRW)
{
    long channel;
    zend_string* data = NULL;

    ZEND_PARSE_PARAMETERS_START(2, 2)
        Z_PARAM_LONG(channel)
        Z_PARAM_STR(data)
    ZEND_PARSE_PARAMETERS_END();


    long ret = wiringPiSPIDataRW(channel, ZSTR_VAL(data), ZSTR_LEN(data));
    RETURN_LONG(ret);
}